package br.com.simtecnologia.access.controll;

import br.com.caelum.vraptor.resource.ResourceMethod;
import br.com.simtecnologia.access.controll.annotation.ControlledResource;

public class AccessControllUtil {
	/**
	 * Check the {@link LoginSession} associated with the Resource send, the logic method
	 * its not check.
	 */
	public static Class<? extends LoginSession> getSessionClassFromResource(ResourceMethod method) {
		ControlledResource resource = method.getResource().getType().getAnnotation(ControlledResource.class);
		return resource == null || resource.sessionClass().equals(LoginSession.class) ? 
				DefaultLoginSession.class : resource.sessionClass();
	}
	
}
